package cn.ichar.es.es;

import cn.ichar.es.es.modular.DocBean;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author: zhangning
 * @Date: 2021/9/9
 */
@RestController
public class ElasticController {
    @Resource
    IElasticService iElasticService;

    @GetMapping("/createIndex")
    public String createIndex() {
        iElasticService.createIndex();
        return "ok";
    }

    @GetMapping("/deleteIndex")
    public String deleteIndex(String index) {
        iElasticService.deleteIndex(index);
        return "ok";
    }

    @GetMapping("/save")
    public String save(@RequestBody DocBean docBean) {
        iElasticService.save(docBean);
        return "ok";
    }

    @GetMapping("/query")
    public Page<DocBean> query(String key) {
        return iElasticService.query(key);
    }
}
